<style lang="less">
    @import '../../../styles/loading.less';
</style>

<template>
    <div>
        <div id="editorElem" style="text-align:left"></div>
    </div>
</template>

<script>
  import E from 'wangeditor'
  import url from '@/config/url'

  export default {
    name: 'w-editor',
    props: {
      content: {
        type: String,
        default () {
          return ''
        }
      }
    },
    data () {
      return {
        spinShow: true,
        editor: null,
        contentInline: this.content
      }
    },
    methods: {
      setContent (content) {
        this.editor.txt.html(content)
      }
    },
    mounted () {
      let editor = new E('#editorElem')
      editor.customConfig.onchange = (html) => {
        this.$emit('update:content', html)
      }
      editor.customConfig.uploadFileName = 'files[]'
      editor.customConfig.uploadImgServer = url.upload  // 上传图片到服务器
      editor.customConfig.uploadImgParams = {token: this.$store.state.access_token}
      editor.create()
      this.editor = editor
      this.spinShow = false
    },
    destroyed () {
    }
  }
</script>

<style>

</style>
